package cn.wolfcode.service.impl;

import cn.wolfcode.domain.Business;
import cn.wolfcode.mapper.BusinessMapper;
import cn.wolfcode.query.BusinessQueryObject;
import cn.wolfcode.service.IBusinessService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BusinessService implements IBusinessService {

    @Autowired
    private BusinessMapper businessMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return businessMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Business record) {
        return businessMapper.insert(record);
    }

    @Override
    public Business selectByPrimaryKey(Long id) {
        return businessMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Business> selectAll() {
        return businessMapper.selectAll();
    }

    @Override
    public int updateByPrimaryKey(Business record) {
        return businessMapper.updateByPrimaryKey(record);
    }

    @Override
    public PageInfo<Business> list(BusinessQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Business> list = businessMapper.selectForList(qo);
        PageInfo pageInfo = new PageInfo(list);
        return pageInfo;
    }

    @Override
    public List<Business> selectMainStore(int mainStore) {

        return businessMapper.selectMainStore(mainStore);
    }
}
